package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.util.Objects;

@Entity
@Table(name = "REPAIR_ORDER_DETAILS", schema = "CRM", catalog = "")
public class RepairOrderDetails {
    private long rodId;
    private String rodName;
    private Long rodNumber;
    private String rodUompany;
    private Long rodUnitprice;
    private String rodSize;
    private String rodColor;
    private RepairOrder repairOrder;
    @ManyToOne
    @JoinColumn(name = "repair_id", referencedColumnName = "repair_id")
    public RepairOrder getRepairOrder() {
        return repairOrder;
    }

    public void setRepairOrder(RepairOrder repairOrder) {
        this.repairOrder = repairOrder;
    }

    @Id
    @Column(name = "ROD_ID", nullable = false, precision = 0)
    @GeneratedValue(generator = "seq",strategy = GenerationType.SEQUENCE)
    //定义一个序列生成器
    @SequenceGenerator(name = "seq",sequenceName = "crm",
            initialValue = 1,allocationSize = 1)
    public long getRodId() {
        return rodId;
    }

    public void setRodId(long rodId) {
        this.rodId = rodId;
    }

    @Basic
    @Column(name = "ROD_NAME", nullable = true, length = 20)
    public String getRodName() {
        return rodName;
    }

    public void setRodName(String rodName) {
        this.rodName = rodName;
    }

    @Basic
    @Column(name = "ROD_NUMBER", nullable = true, precision = 0)
    public Long getRodNumber() {
        return rodNumber;
    }

    public void setRodNumber(Long rodNumber) {
        this.rodNumber = rodNumber;
    }

    @Basic
    @Column(name = "ROD_UOMPANY", nullable = true, length = 20)
    public String getRodUompany() {
        return rodUompany;
    }

    public void setRodUompany(String rodUompany) {
        this.rodUompany = rodUompany;
    }

    @Basic
    @Column(name = "ROD_UNITPRICE", nullable = true, precision = 2)
    public Long getRodUnitprice() {
        return rodUnitprice;
    }

    public void setRodUnitprice(Long rodUnitprice) {
        this.rodUnitprice = rodUnitprice;
    }

    @Basic
    @Column(name = "ROD_SIZE", nullable = true, length = 20)
    public String getRodSize() {
        return rodSize;
    }

    public void setRodSize(String rodSize) {
        this.rodSize = rodSize;
    }

    @Basic
    @Column(name = "ROD_COLOR", nullable = true, length = 20)
    public String getRodColor() {
        return rodColor;
    }

    public void setRodColor(String rodColor) {
        this.rodColor = rodColor;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RepairOrderDetails that = (RepairOrderDetails) o;
        return rodId == that.rodId &&
                Objects.equals(rodName, that.rodName) &&
                Objects.equals(rodNumber, that.rodNumber) &&
                Objects.equals(rodUompany, that.rodUompany) &&
                Objects.equals(rodUnitprice, that.rodUnitprice) &&
                Objects.equals(rodSize, that.rodSize) &&
                Objects.equals(rodColor, that.rodColor);
    }

    @Override
    public int hashCode() {
        return Objects.hash(rodId, rodName, rodNumber, rodUompany, rodUnitprice, rodSize, rodColor);
    }
}
